package com.hy.heath.controller;

import com.hy.heath.common.R;
import com.hy.heath.pojo.entity.Appointment;
import com.hy.heath.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/appointment")
public class AppointmentController {

    @Autowired
    private AppointmentService appointmentService;

    @PostMapping("/create")
    public R<String> createAppointment(@RequestBody Appointment appointment) {
        appointmentService.createAppointment(appointment);
        return R.success("Appointment created successfully");
    }


    @GetMapping("/get/{id}")
    public R<Appointment> getAppointment(@PathVariable Integer id) {
        Appointment appointment = appointmentService.getAppointment(id);
        return R.success(appointment);
    }

    @PutMapping("/update")
    public R<String> updateAppointment(@RequestBody Appointment appointment) {
        appointmentService.updateAppointment(appointment);
        return R.success("Appointment updated successfully");
    }
}

